package com.bkhc.common.enu;

import com.fasterxml.jackson.annotation.JsonValue;

/**
 * @author pcq
 */

public enum EmployeeTypeEnum {
    Partner(0, "合作伙伴"),Employee(1, "员工");
    // 成员变量
    @JsonValue
    private String name;

    private int code;
    // 构造方法
    private EmployeeTypeEnum(int code, String name) {
        this.code = code;
        this.name = name;
    }
    private EmployeeTypeEnum(String name) {
        this.name = name;
        this.code = getCode(name);
    }

    public static String getName(int code) {
        for (EmployeeTypeEnum c : EmployeeTypeEnum.values()) {
            if (c.getCode() == code) {
                return c.name;
            }
        }
        return null;
    }

    public static EmployeeTypeEnum getEmployeeTypeEnum(String name) {
        for (EmployeeTypeEnum c : EmployeeTypeEnum.values()) {
            if (c.getName().equals(name) ) {
                return c;
            }
        }
        return null;
    }
    public static int getCode(String name) {
        for (EmployeeTypeEnum c : EmployeeTypeEnum.values()) {
            if (c.getName() .equals(name) ) {
                return c.code;
            }
        }
        return 0;
    }
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

}
